﻿Imports System.Data.SqlClient

Public Class clsPAISES
    Public Function GUARDA_PAIS(ByVal ALFA2 As String, ByVal PAIS As String, ByVal NUMERICO As Integer, ByVal ALFA3 As String) As Integer
        Dim sql As String = "Insert Into PAISES VALUES(" & _
                           "@ALFA2," & _
                           "@PAIS," & _
                           "@NUMERICO," & _
                           "@ALFA3)"




        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = InitialConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("ALFA2", ALFA2)
        Command.Parameters.AddWithValue("PAIS", PAIS)
        Command.Parameters.AddWithValue("NUMERICO", NUMERICO)
        Command.Parameters.AddWithValue("ALFA3", ALFA3)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
            If RowsAffected > 0 Then
                cnConn.Close()
                GUARDA_PAIS = 1
            Else
                If cnConn.State = ConnectionState.Open Then
                    cnConn.Close()
                End If
                GUARDA_PAIS = 2
            End If
        Catch ex As Exception
            GUARDA_PAIS = -1
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
        End Try

    End Function
End Class
